﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace ZhiAo.CommonLibrary
{
    public static class UIControlExtend
    {
        public static void ECIFocus(this TextBox key)
        {
            ECIFocus(key.ClientID);
        }

        public static void AutoUpper(this TextBox key)
        {
            key.Attributes.CssStyle.Add("text-transform", "uppercase");
        }

        public static void ECIFocus(this DropDownList key)
        {
            ECIFocus(key.ClientID);
        }

        public static void ECIFocus(string id)
        {
            PageHelper.CurrentPage.Form.Attributes.Add("focus", id);
        }

        public static bool IsEmpty(this TextBox key)
        {
            return key.Text.Trim() == "";
        }

        public static string RenderToString(this System.Web.UI.Control control)
        {
            System.IO.StringWriter tw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
            control.RenderControl(hw);
            return tw.ToString();
        }
    }
}
